1. Field of the Invention
The present invention relates to a method and apparatus that enhance an image based on histogram equalization. More particularly, the present invention relates to an image enhancing apparatus and method that improve the contrast of an output image by maintaining the brightness of a corresponding input image.
This application is based on Korean Patent Application No. 98-55038 (filed on Dec. 15, 1998) which is incorporated herein by reference.
2. Description of the Related Art
In a histogram equalization operation, an input image is modified in accordance with a histogram of the input image. In one application, the histogram represents the gray level distribution of the input image, and the content of the gray level distribution provides a global description of the appearance of the input image. By properly adjusting the gray level distribution of the input image in accordance with the distribution of pixels of the image, the contrast and appearance of the image is enhanced.
FIG. 1 is a block diagram of a general histogram equalizer that performs a histogram equalization operation on pixels I(x,y) (x=1 to p; y=1 to q) of an input image {X}. Each of the pixels I(x,y) of the input image {X} has one of L discrete gray levels (i.e. {X0, X1, . . . , XLxe2x88x921}) and is located at a spatial position (x,y). The gray level X0 equals 0 and represents a black level, and the gray level XLxe2x88x921 equals 1 and represents a white level.
As shown in the figure, the histogram equalizer comprises a histogram detector 102, a probability density function (xe2x80x9cPDFxe2x80x9d) calculator 104, a PDF integrator 106, and a nonlinear mapper 108. The histogram detector 102 calculates an occurrence frequency nk. The occurrence frequency nk represents the number of times that the pixels I(x,y) have a gray level corresponding to {Xk|kxcex5{0, 1, 2, . . . , Lxe2x88x921}}. In other words, the detector 102 calculates the number of times n0 that the pixels I(x,y) have the gray level X0, the number of times n1 that the pixels I(x,y) have the gray level X1, etc. The PDF calculator 104 calculates a probability density function P(Xk) based on the occurrence frequency nk of the pixels in accordance with equation (1):
P(Xk)=nk/Nxe2x80x83xe2x80x83(1)
In equation (1), the probability density function P(Xk) represents the probability that a pixel of the input image {X} has the k-th gray level Xk, nk represents the number of times that the k-th gray level Xk appears in the image {X}, and N represents the number of total pixels of the image {X}.
The PDF integrator 106 calculates a cumulative density function (xe2x80x9cCDFxe2x80x9d) c(x) by integrating the probability density function P(Xk) calculated by the PDF calculator 104. Specifically, the cumulative density function c(X) is determined based on equation (2):                               c          ⁡                      (            X            )                          =                              ∑                          i              =              0                                      L              -              1                                ⁢                      xe2x80x83                    ⁢                      P            ⁡                          (                              X                i                            )                                                          (        2        )            
The nonlinear mapper 108 modifies the input pixels I(x,y) of the input image {X} based on the cumulative density function c(X) to produce output pixels IH(x,y) for the image {X}. Specifically, the mapper 108 uses the cumulative density function c(X) as a mapping function to perform a nonlinear mapping operation on the input pixels I(x,y) to produce the output pixels IH(X,y). By modifying the input pixels I(x,y) in such a way to produce the output pixels IH(x,y), the gray levels of the image {X} have a wider dynamic range so that the contrast of the image {X} is enhanced.
FIG. 2 illustrates how the input pixels I(x,y) are transformed into the output pixels IH(x,y) by using the cumulative density function as nonlinear mapping function when most of the gray levels the input pixels I(x,y) have a relatively high brightness level. Specifically, the gray levels of the input pixels I(x,y) are concentrated in the gray level range {Xixcx9cXLxe2x88x921}. The input pixels I(x,y) are modified to produce the output pixels IH(x,y) by re-distributing the gray level range {Xixcx9cXLxe2x88x921} of the input pixels I(x,y) over a wider range {f(Xi)xcx9cf(XLxe2x88x921)} based on the cumulative density function c(X). Since the gray level range {f(Xi)xcx9cf(XLxe2x88x921)} of the output pixels IH(x,y) is greater than the range {Xixcx9cXLxe2x88x921} of the input pixels I(x,y), the contrast of the output image {X} is enhanced.
As described above, the apparatus shown in FIG. 1 uses histogram equalization to enhance the contrast of an input image by evenly distributing the gray levels of the image over a predetermined dynamic range. Also, the contrast of the image is greatly enhanced with a minimal amount of computation, and thus, the apparatus is widely used for enhancing the contrast of images.
However, a serious problem arises when the histogram equalization operation is performed by the apparatus in FIG. 1. Specifically, since the cumulative density function is directly used as a mapping function to change the distribution of the gray levels of the input image, the mean brightness of the output image may substantially change based on the cumulative density function. In particular, the mean brightness of an image signal, which has been equalized such that the distribution of gray levels is uniform, converges on the middle gray level within the gray level range regardless of the brightness of the input image. Accordingly, when a bright image having a small number of pixels with dark gray levels is displayed on a bright screen, the image is slightly darkened, and thus, the quality of the image is degraded. Consequently, the histogram equalization operation performed by the apparatus is only used when a relatively dark image is displayed on dark screen. Thus, the histogram equalization operation performed by the apparatus is not used in a television or camcorder.
In other words, when using the histogram equalization operation described above to make the histogram distribution of an image uniform, the mean brightness converges on the middle level of the gray level range regardless of the brightness of the input image. Thus, the overall brightness in a dark screen increases, and thus, an invisible area of the dark screen becomes visible and enhances the image quality. However, the overall brightness in a light screen decreases with the contrast enhancement, and the image displayed on the light screen appears unnatural.
One object of the present invention is to provide an image enhancing apparatus in which the difference in mean brightness between an input image and an output image, which has been equalized using histogram equalization, is predicted. Then, the predicted result is reflected on the equalized output image signal to maintain the brightness of the input image in the equalized output signal.
Another object of the present invention to provide an image enhancing method in which the difference in mean brightness between an input image and an output image, which has been equalized using histogram equalization, is predicted. Then, the predicted result is reflected on the equalized output image signal to maintain the brightness of the input image in the equalized output signal.
In order to achieve the above and other objects, an image enhancing apparatus is provided. The apparatus comprises: a histogram equalizer circuit that equalizes an input image expressed by a predetermined number of gray levels and outputs a corresponding equalized output image; and a compensator circuit that determines an input mean value of the input image and an output mean value of the equalized output image, determines a mean difference based on the input mean value and the output mean value, and at least indirectly adjusts the equalized output image according to the mean difference.
In order to further achieve the above and other objects, an image enhancing method is provided. The method comprises: (a) equalizing an input image expressed by a predetermined number of gray levels and outputting a corresponding equalized output image; (b) determining an input mean value of the input image and an output mean value of the equalized output image; (c) determining a mean difference based on the input mean value and the output mean value; and (d) adjusting, at least indirectly, the equalized output image according to the mean difference.